package com.io.testIO;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

/**
 * @author keyer
 * @Name : com.cyd.testIO.TestIOUtil
 * @Description : 描述
 * Created by cyd on 2021-04-13 17:00:19
 */
public class TestIoUtil {
    public static void test01() {
        BufferedInputStream in = FileUtil.getInputStream("d:/hello.txt");
        BufferedOutputStream out = FileUtil.getOutputStream("d:/hello2.txt");
        // 复制流
        long copySize = IoUtil.copy(in, out, IoUtil.DEFAULT_BUFFER_SIZE);
        // 追加文字
        IoUtil.writeUtf8(out, false, "\nsb", "\nsb2", "\nsb3");
        // 关闭流
        IoUtil.close(in);
        IoUtil.close(out);
        System.out.println(copySize);
    }

    public static void main(String[] args) {
        test01();
    }
}
